/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
 * TrainingBook
 * Copyright (C) Arnaud Duval 2010 <arnaud.duval@gmail.com>
 * 
 * Projects is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Projects is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "user-day.hpp"
#include <libxml++/libxml++.h>
#include <iostream>

///@brief Default constructor
UserDay::UserDay()
{
    weight = 0.;
    height = 0.;
    humor = 0;
    sensations = 0;
    restHR = 0;
    maxHR = 0;
}

///@brief Copy contructor
///@param u UserDay object to copy
UserDay::UserDay(const UserDay& u)
{
    date = u.date;
    weight = u.weight;
    height = u.height;
    humor = u.humor;
    sensations = u.sensations;
    restHR = u.restHR;
    maxHR = u.maxHR;
}

///@brief Destructor
UserDay::~UserDay()
{

}

///@brief Overload of = operator
///@param u right operand
UserDay& UserDay::operator=(const UserDay& u)
{
    date = u.date;
    weight = u.weight;
    height = u.height;
    humor = u.humor;
    sensations = u.sensations;
    restHR = u.restHR;
    maxHR = u.maxHR;
    return *this;
}

///@brief Return the date and time
DateTime UserDay::GetDate() const
{
    return date;
}

///@brief Return the weight
double UserDay::GetWeight() const
{
    return weight;
}

///@brief Return the hegight in meters
double UserDay::GetHeight() const
{
    return height;
}

///@brief Return the humor index
unsigned int UserDay::GetHumor() const
{
    return humor;
}

///@brief Return the sensations index
unsigned int UserDay::GetSensations() const
{
    return sensations;
}

///@brief Return the rest hearth rate
unsigned int UserDay::GetRestHR() const
{
    return restHR;
}

///@brief Return the maximum hearth rate
unsigned int UserDay::GetMaxHR() const
{
    return maxHR;
}

///@brief Set the date and time
///@param theDate DateTime value to be set
void UserDay::SetDate(DateTime theDate)
{
    date = theDate;
}

///@brief Set the weight
///@param theWeight Weight value to set
void UserDay::SetWeight(double theWeight)
{
    weight = theWeight;
}

///@brief Set the height
///@param theHeight Height value to set
void UserDay::SetHeight(double theHeight)
{
    height = theHeight;
}

///@brief Set the humor index
///@param theHumor humor index value to set
void UserDay::SetHumor(unsigned int theHumor)
{
    humor = theHumor;
}

///@brief Set the sensations index
///@param theSensations Sensation index value to set
void UserDay::SetSensations(unsigned int theSensations)
{
    sensations = theSensations;
}

///@brief Set the rest hearth rate
///@param theRestHR Rest hearth rate value to set
void UserDay::SetRestHR(unsigned int theRestHR)
{
    restHR = theRestHR;
}

///@brief Set the maximum hearth rate
///@param theMaxHR Maximum hearth rate value to set
void UserDay::SetMaxHR(unsigned int theMaxHR)
{
    maxHR = theMaxHR;
}

/*
///@brief Read informations from a XML node
///@param currentNode Pointer to XML node to read
void UserDay::ReadXMLNode(xmlpp::Node* currentNode)
{

}*/

///@brief Write to XML file
///@param fout out stream to XML file
void UserDay::WriteXML(std::ofstream& fout)
{
    fout << "\t\t\t<Date>" << date << "</Date>\n";
    fout << "\t\t\t<Weight>" << weight << "</Weight>\n";
    fout << "\t\t\t<Height>" << height << "</Height>\n";
    fout << "\t\t\t<Humor>" << humor << "</Humor>\n";
    fout << "\t\t\t<Sensations>" << sensations << "</Sensations>\n";
    fout << "\t\t\t<RestHR>" << restHR << "</RestHR>\n";
    fout << "\t\t\t<MaxHR>" << maxHR << "</MaxHR>\n";
}

///@brief Overload of << operator
///@param s Out stream
///@param u UserDay object to put in the out stream
std::ostream &operator << (std::ostream& s, const UserDay& u)
{
    s << "Date :\t" << u.date << "\n";
    s << "Weight :\t" << u.weight << "\n";
    s << "Height :\t" << u.height << "\n";
    s << "Humor :\t" << u.humor << "\n";
    s << "Sensations :\t" << u.sensations << "\n";
    s << "Rest HR :\t" << u.restHR << "\n";
    s << "Max HR :\t" << u.maxHR << "\n";
    return s;
}